package ru.usu.gv.core;

import com.sun.j3d.utils.universe.SimpleUniverse;

import ru.usu.gv.gui.GUIEngine;

import javax.media.j3d.Canvas3D;
import javax.swing.JFrame;
import javax.swing.JPopupMenu;

/**
 * @author: Sergey Pupyrev 
 * Apr 2, 2006
 */

public class GraphVisMain extends JFrame
{
	private static final long serialVersionUID = 1L;

	public GraphVisMain()
	{
		GUIEngine.getInstance().init(this);
	}

	private static boolean checkOPENGLVersion()
	{
		Canvas3D canvas3D = new Canvas3D(SimpleUniverse.getPreferredConfiguration());

		String version = (String) canvas3D.queryProperties().get("native.version");
		if (version.compareTo("1.2") < 0)
		{
			System.err.println("This program must be run on OpenGL version 1.3 or higher. Current version is " + version);
			return false;
		}
		return true;
	}

	public static void main(String[] args)
	{
		JPopupMenu.setDefaultLightWeightPopupEnabled(false);

		if (checkOPENGLVersion())
		{
			GraphVisMain mainFrame = new GraphVisMain();

			mainFrame.setSize(1024, 768);
			if (mainFrame.getTitle() == null)
				mainFrame.setTitle("GraphVis");
			mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			mainFrame.setVisible(true);
		}
	}
}
